package com.mask.chapter01;

import java.util.function.Predicate;

public class Test4 {
    public static void main(String[] args) {
        int array[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
        System.out.println("输出偶数:");
        print( array  , e -> e%2==0);     //
        System.out.println("输出所有3的倍数:");
        print( array , e -> e % 3 == 0 );     //
    }

    public static void print(int []array,Predicate<Integer> filter) {
        for(int i:array) {
            if( filter.test(i))
                System.out.println(i);
        }
    }
}